/**
 * 开关组
 */
var CustomToggleGroup = ccui.Layout.extend({
    /**
     * 关联的开关
     */
    toggleArr: [],
    /**
     * 是否可以点击关闭
     */
    allowSwitchOff: false,
    /**
     * window
     */
    parentNode: null,

    ctor: function (toggleArr, allowSwitchOff, parentNode) {
        this._super();
        this.toggleArr = toggleArr;
        this.allowSwitchOff = allowSwitchOff;
        this.parentNode = parentNode;
    },

    /**
     * 有开关打开
     * @param toggle
     */
    changeOn: function (toggle) {
        for (var i = 0; i < this.toggleArr.length; i++) {
            var toggleArrElement = this.toggleArr[i];
            var toggleObj = this.getNode(this.parentNode, toggleArrElement);
            toggleObj.IsOn = toggle == toggleObj;
            toggleObj.changeFocus();
        }
    },
    /**
     * 取得node
     * @param node
     * @param str
     */
    getNode: function (node, str) {
        var names = str.split(".");
        for (var i = 0; i < names.length; i++) {
            node = node[names[i]];
        }
        return node;
    }
});